package com.sk.cardeal.act.settlement;

import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.zxing.WriterException;
import com.sk.cardeal.R;
import com.sk.cardeal.base.BaseActivity;
import com.sk.cardeal.zxing.encoding.EncodingHandler;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by sk on 2018/4/18.
 */

public class AliPayActivity extends BaseActivity {
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.tv_type)
    TextView tvType;
    @BindView(R.id.qr_code)
    ImageView qrCode;
    @BindView(R.id.cash_his)
    TextView cashHis;

    @Override
    protected int getContentView() {
        return R.layout.activity_alipay;
    }

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        String data = getIntent().getStringExtra("data");
        Bitmap mBitmap = null;
        try {
            mBitmap = EncodingHandler.createQRCode(data, 300);
            if (mBitmap != null) {
                Drawable drawable = new BitmapDrawable(mBitmap);
                qrCode.setBackground(drawable);
            }
        } catch (WriterException e) {
            e.printStackTrace();
        }
    }

    @OnClick({R.id.back, R.id.cash_his})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.cash_his:
                break;
        }
    }
}
